package com.example.demo.service.impl;

import com.example.demo.bean.PhotoTooLargeException;
import com.example.demo.service.OssService;
import com.example.demo.service.PhotoService;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public class PhotoServiceImpl implements PhotoService {
    private static  OssService ossService = new OssServiceImpl();

    @Override
    public String getUrl(String key) {
        return ossService.getUrl(key).toString();
    }

    @Override
    public void upload(String key,File file) throws IOException, PhotoTooLargeException {
        //控制大小
        long size = file.length();
        long mb = size/1024/1024;
        if(mb>20){
            throw new PhotoTooLargeException();
        }
        ossService.upload(key,file);
    }



    @Override
    public void delete(String key) {

    }
}
